package com.sunday.common.mq.rocket.brave.study.apache.e6_Brave_Trace;

import com.sunday.common.mq.rocket.brave.DefaultTracingRocketMQListener;
import com.sunday.common.mq.rocket.brave.RocketTracing;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.autoconfigure.ListenerContainerConfiguration;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * {@link ListenerContainerConfiguration#registerContainer(String, Object, RocketMQMessageListener)}
 * {@link ListenerContainerConfiguration#createRocketMQListenerContainer(String, Object, RocketMQMessageListener)}
 */
@Slf4j
@Service
@RocketMQMessageListener(
        topic = "your_topic",
        consumerGroup = "your_consumer_group_name",
        consumeThreadNumber = 1
)
public class MessageExtConsumer extends DefaultTracingRocketMQListener implements RocketMQListener<MessageExt> {

    public MessageExtConsumer(RocketTracing rocketTracing) {
        super(rocketTracing);
    }

    @Override
    public void onMessage(MessageExt message) {
//        log.info("{} - {}", new String(message.getBody()), message);
//        try {
//            TimeUnit.SECONDS.sleep(10);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        log.info("[business]=====================");
    }

}